/**
 * <pre>
 * Title: 		VmStatus.java
 * Project: 	MSBASE
 * Author:		linriqing
 * Create:	 	2012-12-20 下午05:45:01
 * Copyright: 	Copyright (c) 2012
 * Company:		Shenzhen Helper
 * <pre>
 */
package com.hengpeng.common.monitor.dto;

import java.io.Serializable;
import java.lang.Thread.State;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.hengpeng.common.web.annotation.HtmlInput;
import com.hengpeng.common.web.annotation.HtmlInputPattern;
import com.hengpeng.common.web.annotation.HtmlInputType;

/**
 * <pre>
 * Java虚拟机状态
 * </pre>
 * @author linriqing
 * @version 1.0, 2012-12-20
 */
public class VmStatus implements Serializable
{
	/**
	 * <pre>
	 * Java虚拟机垃圾回收状态
	 * </pre>
	 * @author linriqing
	 * @version 1.0, 2012-12-24
	 */
	public static class GcStatus implements Serializable
	{
		private static final long serialVersionUID = -4005414071470647140L;

		/**
		 * 回收次数
		 */
		@HtmlInput(label = "回收次数", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.INT)
		private long count;

		/**
		 * 垃圾回收类型名称
		 */
		@HtmlInput(label = "垃圾回收类型名称", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.NORMAL)
		private String name;

		/**
		 * 回收花费时间
		 */
		@HtmlInput(label = "回收花费时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.INT)
		private long time;

		/**
		 * 构造函数
		 * @param name 垃圾回收类型名称
		 * @param time 回收花费时间
		 * @param count 回收次数
		 */
		public GcStatus(String name, long time, long count)
		{
			super();
			this.name = name;
			this.time = time;
			this.count = count;
		}

		/**
		 * @return 回收次数
		 */
		public long getCount()
		{
			return count;
		}

		/**
		 * @return 垃圾回收类型名称
		 */
		public String getName()
		{
			return name;
		}

		/**
		 * @return 回收花费时间
		 */
		public long getTime()
		{
			return time;
		}

	}

	/**
	 * <pre>
	 * 内存使用状态
	 * </pre>
	 * @author linriqing
	 * @version 1.0, 2012-12-24
	 */
	public static class MemoryUsage implements Serializable
	{
		private static final long serialVersionUID = 5403189349328875088L;

		/**
		 * 已提交内存大小
		 */
		@HtmlInput(label = "已提交内存大小", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.INT)
		private long committed;

		/**
		 * 初始内存大小
		 */
		@HtmlInput(label = "初始内存大小", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.INT)
		private long init;

		/**
		 * 最大内存
		 */
		@HtmlInput(label = "最大内存", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.INT)
		private long max;

		/**
		 * 已使用内存
		 */
		@HtmlInput(label = "已使用内存", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.INT)
		private long used;

		/**
		 * 构造函数
		 * @param init 初始内存大小
		 * @param used 已使用内存
		 * @param committed 已提交内存大小
		 * @param max 最大内存
		 */
		public MemoryUsage(long init, long used, long committed, long max)
		{
			super();
			this.init = init;
			this.used = used;
			this.committed = committed;
			this.max = max;
		}

		/**
		 * @return 已提交内存大小
		 */
		public long getCommitted()
		{
			return committed;
		}

		/**
		 * @return 初始内存大小
		 */
		public long getInit()
		{
			return init;
		}

		/**
		 * @return 最大内存
		 */
		public long getMax()
		{
			return max;
		}

		/**
		 * @return 已使用内存
		 */
		public long getUsed()
		{
			return used;
		}
	}

	/**
	 * <pre>
	 * Java线程状态
	 * </pre>
	 * @author linriqing
	 * @version 1.0, 2012-12-24
	 */
	public static class ThreadStatus implements Serializable
	{
		private static final long serialVersionUID = 4194208146019323203L;

		/**
		 * 线程名
		 */
		@HtmlInput(label = "线程名", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.NORMAL)
		private String name;

		/**
		 * 线程状态
		 */
		@HtmlInput(label = "线程状态", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.NORMAL)
		private State state;

		/**
		 * 构造函数
		 * @param name 线程名
		 * @param state 线程状态
		 */
		public ThreadStatus(String name, State state)
		{
			super();
			this.name = name;
			this.state = state;
		}

		/**
		 * @return name 线程名
		 */
		public String getName()
		{
			return name;
		}

		/**
		 * @return 线程状态
		 */
		public State getState()
		{
			return state;
		}
	}

	private static final long serialVersionUID = 2720006242156659043L;

	@HtmlInput(label = "Java虚拟机启动参数", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.NORMAL)
	private String bootParameters;

	@HtmlInput(label = "空闲内存大小", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.FLOAT)
	private double freeMemory;

	private List<GcStatus> gcStatus = new ArrayList<GcStatus>();

	private MemoryUsage heapMemory;

	@HtmlInput(label = "最大内存大小", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.FLOAT)
	private double maxMemory;

	@HtmlInput(label = "Java虚拟机名称", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.NORMAL)
	private String name;

	private MemoryUsage nonHeapMemory;

	@HtmlInput(label = "Java虚拟机启动时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIMESS)
	private Date startTime;

	private List<ThreadStatus> threadStatus = new ArrayList<ThreadStatus>();

	@HtmlInput(label = "已分配总内存大小", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.FLOAT)
	private double totalMemory;

	@HtmlInput(label = "Java虚拟机已启动时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.INT)
	private long upTime;

	@HtmlInput(label = "Java虚拟机提供商", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.NORMAL)
	private String vendor;

	@HtmlInput(label = "Java虚拟机版本", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.NORMAL)
	private String version;

	/**
	 * @return bootParameters
	 */
	public String getBootParameters()
	{
		return bootParameters;
	}

	/**
	 * @return vmFreeMemory
	 */
	public double getFreeMemory()
	{
		return freeMemory;
	}

	/**
	 * @return gcStatus
	 */
	public List<GcStatus> getGcStatus()
	{
		return gcStatus;
	}

	/**
	 * @return heapMemory
	 */
	public MemoryUsage getHeapMemory()
	{
		return heapMemory;
	}

	/**
	 * @return vmMaxMemory
	 */
	public double getMaxMemory()
	{
		return maxMemory;
	}

	/**
	 * @return name
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * @return nonHeapMemory
	 */
	public MemoryUsage getNonHeapMemory()
	{
		return nonHeapMemory;
	}

	/**
	 * @return startTime
	 */
	public Date getStartTime()
	{
		return startTime;
	}

	/**
	 * @return threadStatus
	 */
	public List<ThreadStatus> getThreadStatus()
	{
		return threadStatus;
	}

	/**
	 * @return vmTotalMemory
	 */
	public double getTotalMemory()
	{
		return totalMemory;
	}

	/**
	 * @return upTime
	 */
	public long getUpTime()
	{
		return upTime;
	}

	/**
	 * @return vendor
	 */
	public String getVendor()
	{
		return vendor;
	}

	/**
	 * @return version
	 */
	public String getVersion()
	{
		return version;
	}

	/**
	 * @param bootParameters bootParameters
	 */
	public void setBootParameters(String bootParameters)
	{
		this.bootParameters = bootParameters;
	}

	/**
	 * @param vmFreeMemory vmFreeMemory
	 */
	public void setFreeMemory(double vmFreeMemory)
	{
		this.freeMemory = vmFreeMemory;
	}

	/**
	 * @param heapMemory heapMemory
	 */
	public void setHeapMemory(MemoryUsage heapMemory)
	{
		this.heapMemory = heapMemory;
	}

	/**
	 * @param vmMaxMemory vmMaxMemory
	 */
	public void setMaxMemory(double vmMaxMemory)
	{
		this.maxMemory = vmMaxMemory;
	}

	/**
	 * @param name name
	 */
	public void setName(String name)
	{
		this.name = name;
	}

	/**
	 * @param nonHeapMemory nonHeapMemory
	 */
	public void setNonHeapMemory(MemoryUsage nonHeapMemory)
	{
		this.nonHeapMemory = nonHeapMemory;
	}

	/**
	 * @param startTime startTime
	 */
	public void setStartTime(Date startTime)
	{
		this.startTime = startTime;
	}

	/**
	 * @param vmTotalMemory vmTotalMemory
	 */
	public void setTotalMemory(double vmTotalMemory)
	{
		this.totalMemory = vmTotalMemory;
	}

	/**
	 * @param upTime upTime
	 */
	public void setUpTime(long upTime)
	{
		this.upTime = upTime;
	}

	/**
	 * @param vendor vendor
	 */
	public void setVendor(String vendor)
	{
		this.vendor = vendor;
	}

	/**
	 * @param version version
	 */
	public void setVersion(String version)
	{
		this.version = version;
	}
}
